<?php  include VIEWPATH.'common/head.php';  ?>
    <script type="text/javascript">
        var status = '<?php echo $_GET['status'];?>';
        if(status == '-1'){
            alert('fail:<?php echo $_GET['msg'];?>');
        }
        function del_label(level, id){
            if(!confirm("确定删除吗？")){
                return false;
            }
            var url = "index.php?c=label&m=del_label&level=" + level + "&id=" + id;
            $.ajax({
                type:'get',
                url: url,
                data:{},
                cache:false,
                dataType:'json',
                success:function(data){
                    if(data.errorCode == 0) {
                        //表单提交
                        window.location.href = window.location.href;
                        return;
                    }else{
                        alert(data.errorMsg);
                    }
                },
                error:function(data){
                    alert(data);
                }
            });
        }
    </script>
    <style>
        .tag-category{padding-left: 20px;padding-right: 20px;position: relative;}
        .tag-label{border-color: rgba(0, 153, 204, 1);color: rgba(0, 153, 204, 1);padding-left: 30px;
            padding-right: 30px;padding-top: 5px;padding-bottom:5px;height:auto;position: relative;margin-right: 20px;
            margin-bottom: 10px;margin-top: 10px;}
        .tag-add{border-color: red;color: red;padding-left: 20px;padding-right: 20px;
            padding-top: 5px;padding-bottom: 5px;height: auto;float: right; margin-top: 10px;}
        .del_tag{position: absolute;top: -1px;left: 10px;color: red;font-size: 16px;}
        .tag-label-list{float: left;width: 85%;}
        .tag-level{margin-bottom: 10px;}
        .level-active{background: #dbe8ff;}
        .tag-level-list{float: left;}
        .tag-level-name{float: left;display: block;padding: 10px;border: 1px solid #a3a0a0;padding-left: 20px;padding-right: 20px;position: relative;}
        .add-level{padding-left: 30px;padding-right: 30px;float: right;margin-top: 5px;}
    </style>
    <body class="gray-bg">
    <div class="wrapper wrapper-content ">

        <div class="add-btn" style="float:right;">
            <div class="modal fade" id="label_add" tabindex="-1" role="dialog" aria-labelledby="item_category_addLabel">
                <div class="modal-dialog" role="document" aria-hidden="true" style="width: 70%;"><div class="modal-content"></div></div>
            </div>
        </div>
        <div class="clearfix"></div>
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <div class="table-responsive">
                            <div class="tag-level">
                                <div class="tag-level-list">
                                    <?php foreach($categoryList as $category) { ?>
                                        <div class="tag-level-name <?php echo $category["id"] == $id ? "level-active" : "";?>">
                                            <a href="index.php?c=label&m=category&id=<?php echo $category["id"];?>"><?php echo $category["name"];?></a>
                                            <a href="javascript:void(0)" onclick="del_label(0, <?php echo $category["id"];?>)" class="del_tag">x</a>
                                            <a href="index.php?c=label&m=add_category&id=<?php echo $category["id"];?>" data-toggle="modal" data-target="#label_add">
                                                <span class="item-glyphicon glyphicon glyphicon-pencil" aria-hidden="true"></span>
                                            </a>
                                        </div>
                                    <?php } ?>
                                    <div class="clearfix"></div>
                                </div>
                                <a href="index.php?c=label&m=add_category" data-toggle="modal" data-target="#label_add" class="btn btn-danger add-level">添加类型</a>
                                <div class="clearfix"></div>
                            </div>
                            <table class="table table-bordered table-hover">
                                <thead>
                                    <tr>
                                        <th>标签分组</th>
                                        <th>标签名称</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php foreach($labelList as $label){ ?>
                                        <tr>
                                            <td>
                                                <div class="btn btn-white tag-category">
                                                    <?php echo $label["name"];?>
                                                    <a href="javascript:void(0)" onclick="del_label(1, <?php echo $label["id"];?>)" class="del_tag">x</a>
                                                    <a href="index.php?c=label&m=add_category&id=<?php echo $label["id"];?>" data-toggle="modal" data-target="#label_add">
                                                        <span class="item-glyphicon glyphicon glyphicon-pencil" aria-hidden="true"></span>
                                                    </a>
                                                </div>
                                            </td>
                                            <td>
                                                <div class="tag-label-list">
                                                    <?php foreach($label["label_list"] as $labelArr){ ?>
                                                        <div class="item_active item_active_col tag-label">
                                                            <?php echo $labelArr["label_name"];?>
                                                            <a href="javascript:void(0)" onclick="del_label(2, <?php echo $labelArr["label_id"];?>)"  class="del_tag">x</a>
                                                        </div>
                                                    <?php }?>
                                                    <div class="clearfix"></div>
                                                </div>
                                                <a href="index.php?c=label&m=add_category_label&fid_0=<?php echo $id;?>&fid_1=<?php echo $label["id"];?>" data-toggle="modal" data-target="#label_add" class="item_active item_active_col tag-add">+ 添加</a>
                                                <div class="clearfix"></div>
                                            </td>
                                        </tr>
                                    <?php } ?>
                                    <?php if(!empty($labelList)){ ?>
                                    <tr>
                                        <td><a href="index.php?c=label&m=add_category&parent_id=<?php echo $id;?>" class="btn btn-danger" data-toggle="modal" data-target="#label_add" style="padding-left: 30px;padding-right: 30px;">添加</a></td>
                                        <td></td>
                                    </tr>
                                    <?php } ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>

        </div>

    </div>
<?php  include VIEWPATH.'common/footer.php';  ?>